package org.appfuse.dao.hibernate.criterion;

import java.io.Serializable;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
 * 
 * 
 * @author <a href="mailto: baiyibing@gmail.com">王锤</a>
 * @version $Revision$
 * 
 */
public class RestrictionParam implements Comparable, Serializable {
	public RestrictionParam(String op, String paraName, Object paraValue) {
		this.op = op;
		this.paraName = paraName;
		this.paraValue = paraValue;
	}

	public String getOp() {
		return op;
	}

	public void setOp(String op) {
		this.op = op;
	}

	public String getParaName() {
		return paraName;
	}

	public void setParaName(String paraName) {
		this.paraName = paraName;
	}

	public Object getParaValue() {
		return paraValue;
	}

	public void setParaValue(Object paraValue) {
		this.paraValue = paraValue;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 9211518389966270377L;
	private String op;
	private String paraName;
	private Object paraValue;

	/**
	 * @see java.lang.Comparable#compareTo(Object)
	 */
	public int compareTo(Object object) {
		RestrictionParam myClass = (RestrictionParam) object;
		return new CompareToBuilder().append(this.op, myClass.op).append(
				this.paraName, myClass.paraName).append(this.paraValue,
				myClass.paraValue).toComparison();
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof RestrictionParam)) {
			return false;
		}
		RestrictionParam rhs = (RestrictionParam) object;
		return new EqualsBuilder().appendSuper(super.equals(object)).append(
				this.op, rhs.op).append(this.paraName, rhs.paraName).append(
				this.paraValue, rhs.paraValue).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-141433739, -1034145549).appendSuper(
				super.hashCode()).append(this.op).append(this.paraName)
				.append(this.paraValue).toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("paraValue", this.paraValue)
				.append("hql", this.op).append("paraName", this.paraName)
				.toString();
	}

}
